﻿<?php
/**
 * 题目详细界面
 *
 * @author kinet <380511703@qq.com>
 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
 */

session_start();
require_once( 'path.php' );
require_once( SOJ_ROOT.'/include/function/lib.php');


$tpl = new my_smarty();

//若未登录,则重定向到登录界面
if( empty($_SESSION['admin']) ){

	$_SESSION['success_message'] = 'do not login yet , '.$_SESSION['admin'];
	header( 'Location:../manager/manager_login.php' );
	exit ;
}
//处理由其他页面保存在会话中的错误信息
if( !empty($_SESSION['errors']) ){

	$tpl->assign( 'errors' , $_SESSION['errors']  );
	//清除之前的错误信息
	unset( $_SESSION['errors'] );
}
$request=$_GET;
if( empty( $request['no']) ){
	header('Location:../manager/manager_login.php');
}else{
	$no = $request['no'];
}
try{
 $db = db_connect();
 $problem = new problem_process( $db ) ;
 $problem->load( 'problem_no' , $no ); 
 $problem_test_right=new problem_test_right_process($db);
	 try{
	 $problem_test_right->load('problem_no',$no);
	 }
	 catch(Exception $e){
	  $problem_test_right->set('test0','null');
	  $problem_test_right->set('test1','null');
	  $problem_test_right->set('test2','null');
	  $problem_test_right->set('test3','null');
	  $problem_test_right->set('test4','null');
	  $problem_test_right->set('test5','null');
	  $problem_test_right->set('test6','null');
	  $problem_test_right->set('test7','null');
	  $problem_test_right->set('test8','null');
	  $problem_test_right->set('test9','null');
	  $problem_test_right->set('right0','null');
	  $problem_test_right->set('right1','null');
	  $problem_test_right->set('right2','null');
	  $problem_test_right->set('right3','null');
	  $problem_test_right->set('right4','null');
	  $problem_test_right->set('right5','null');
	  $problem_test_right->set('right6','null');
	  $problem_test_right->set('right7','null');
	  $problem_test_right->set('right8','null');
	  $problem_test_right->set('right0=9','null');
	  
	  
	 }


//@todo 是传入整个数组 由模板判断如何显示 还是传入单独的值?
//可以由db_obj.class提供一个get_all()方法返回所有的值
$problem_no = $no ;
$title = $problem->get('title');
$source = $problem->get('source');
$content = $problem->get('content');
$best_user = $problem->get('best_user');
$time_limit = $problem->get('time_limit');
$mem_limit = $problem->get('mem_limit');
$input = $problem->get('input');
$output = $problem->get('output');
$sample_input = $problem->get('sample_input');
$sample_output = $problem->get('sample_output');
$tip = $problem->get('tip');
$submit_count=$problem->get('submit_count');
$ac_count=$problem->get('ac_count'); 
$tpl->assign( 'problem_no' , $problem_no );
$tpl->assign( 'title' , $title );
$tpl->assign( 'source' , $source );
$tpl->assign( 'best_user' , $best_user );
$tpl->assign( 'time_limit' , $time_limit );
$tpl->assign( 'mem_limit' , $mem_limit );
$tpl->assign( 'content' , $content );
$tpl->assign( 'input' , $input );
$tpl->assign( 'output' , $output );
$tpl->assign( 'sample_input' , $sample_input );
$tpl->assign( 'sample_output' , $sample_output );
$tpl->assign('submit_count',$submit_count);
$tpl->assign('ac_count',$ac_count);
$tpl->assign( 'tip' , $tip );
$tpl->assign( 'test0' , $problem_test_right->get('test0'));
$tpl->assign( 'test1' , $problem_test_right->get('test1'));
$tpl->assign( 'test2' , $problem_test_right->get('test2'));
$tpl->assign( 'test3' , $problem_test_right->get('test3'));
$tpl->assign( 'test4' , $problem_test_right->get('test4'));
$tpl->assign( 'test5' , $problem_test_right->get('test5'));
$tpl->assign( 'test6' , $problem_test_right->get('test6'));
$tpl->assign( 'test7' , $problem_test_right->get('test7'));
$tpl->assign( 'test8' , $problem_test_right->get('test8'));
$tpl->assign( 'test9' , $problem_test_right->get('test9'));
$tpl->assign( 'right0' , $problem_test_right->get('right0'));
$tpl->assign( 'right1' , $problem_test_right->get('right1'));
$tpl->assign( 'right2' , $problem_test_right->get('right2'));
$tpl->assign( 'right3' , $problem_test_right->get('right3'));
$tpl->assign( 'right4' , $problem_test_right->get('right5'));
$tpl->assign( 'right6' , $problem_test_right->get('right6'));
$tpl->assign( 'right7' , $problem_test_right->get('right7'));
$tpl->assign( 'right8' , $problem_test_right->get('right8'));
$tpl->assign( 'right9' , $problem_test_right->get('right9'));
$tpl->display('manager_problem_alter.tpl');
}catch(Exception $e){
	echo $e->getMessage();
}
